﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace WMM.Tapioca.Formula.Aspects
{
    /// <summary>
    /// A fragment OCC rule is an OCC rule that is expressed by the <formula:occFragments> element. 
    /// </summary>
    public class OccFragmentsAspect : OccAspect
    {
        private XElement element;

        internal XElement Element
        {
            get { return element; }
            set { element = value; }
        }

        /// <summary>
        /// Constructor.
        /// </summary>
        public OccFragmentsAspect(XElement occFragmentsAspect)
        {
            this.Element = occFragmentsAspect;

            XElement aspect = occFragmentsAspect.Parent;

            if (aspect.Attribute("source") != null)
            {
                this.Source = aspect.Attribute("source").Value;
            }

            if (occFragmentsAspect.Attribute("source") != null)
            {
                this.Source = occFragmentsAspect.Attribute("source").Value;
            }

            XAttribute occ = occFragmentsAspect.Attribute("occ");

            if (occ != null)
            {
                this.Occ = occ.Value;
            }
        }
    }
}
